home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
fdate61a.zip
/
FDATE.DOC
< prev
next >
Wrap
Text File
|
1992-02-15
|
48KB
|
1,211 lines
FDATE Version 6.1a Feb 14, 1992
===================================================================
FDATE: a utility for date manipulation in batch files.
===================================================================
Stephen Ferg 5113 N. 8th Road, Arlington, VA 22205-1201
Voice (703) 525-2241 CompuServe 73377,1157
=======================================================================
Format:
FDATE /Ffunc /Adate /Bdate /Iformat /Oformat
/Nnum /Ddayofweek /Pstring /Sstring
=======================================================================
FDATE PARAMETERS
================
The parameters that are required depend on the function requested.
Parameters that are specified, but not needed, are ignored.
Executing FDATE without any parameters displays a brief help screen.
Parameters can be in any order and upper or lower case.
Note that although format specifications are not case sensitive,
they ARE "text sensitive". If any characters are missing,
added, or mistyped, the format specification will be rejected.
(A common mistake is to enter "/format" instead of "/Fformat".
This mistake can be avoided by using the /Ff function alias.)
/F requests a particular FDATE function
If this parameter is not specified, or is specified incorrectly,
FDATE displays a help screen. If you unexpectedly get the help
screen displayed, you probably have omitted the /F parameter.
/N number of days (always a number)
/D day-of-week number (used only with W function)
/A date A (for date functions)
/B date B (for date functions)
If the /A parameter is omitted, /Atoday is assumed.
If the /B parameter is omitted, /Btoday is assumed.
/A number A (for math functions)
/B number B (for math functions)
/I specifies format of input date(s)
If the /I parameter is omitted, /Imm-dd-ccyy is assumed.
/O specifies format of output date
If the /O parameter is omitted, /Od1 is assumed.
/L specifies language of output.
/Lus US (American) English-language output
/Lfr French-language output
If the /L parameter is omitted, /Lus [American English] is assumed.
/V specifies that output is to be placed in an environment variable
rather than written to standard output (i.e. to the screen).
/P specifies a prefix string for the output
/S specifies a suffix string for the output
Maximum length for a prefix or suffix string is 80 bytes.
These optional parameters may always be specified or omitted.
They must be enclosed in single quotes, double quotes, or
square brackets
Note that "whitespace" will be removed from these strings,
so formatting of /P and /S strings cannot be controlled using
spaces. To format strings, use periods or ASCII 255 (hex'ff')
as filler.
EXAMPLES
FDATE /Ff /At /Od1 /P"Today is "
FDATE /Fdif /At /B12-25-TTTT /S" days until Christmas"
FDATE /Fdif /At /B12-25-TTTT /P"It is " /S" days 'til Xmas"
FDATE /Ff /A05-08-TTTT /S[ -- "Buffalo Bill's" birthday]
ERROR HANDLING
==============
If FDATE detects an error:
(1) it will return an errorlevel of 1 (rather than 0), and
(2) its output will be 3 lines:
* the word ERROR
* a DOS batch-file ECHO statement that displays an error message
* a DOS batch-file PAUSE statement
If Fdate output is displayed directly, or redirected to NUL:
you can detect an error by testing the errorlevel for a value of 1.
If Fdate output is piped to an environment manipulation utility such
as STRINGS or GET, the environment variable will be set to ERROR.
Errorlevel will be set by STRINGS/GET, and will probably be 0.
In such a case, the only way to detect an error is to test the
environment variable for the value ERROR.
If FDATE output is redirected to a batch file, which is then
CALLed to set an environment variable, the batch file will:
* set the environment variable to ERROR,
* ECHO the error message, and
* pause.
You can detect an error by testing errorlevel for the value 1
either before or after you CALL the batch file.
You can detect an error by testing the environment variable for the
value ERROR, AFTER you have CALLed the batch file.
----------------------------------------------------------------------
EXAMPLE:
rem use FDATE to check validity of year in parm %1
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"Received year parm: "
if errorlevel 1 echo Year parm [%1] is not valid.
if errorlevel 1 goto endit
EXAMPLE:
rem use FDATE to verify %1, and GET to put it into %year%
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy | GET ZE /V%year% >nul
if (%year%)==(ERROR) echo Year parm [%1] is not valid.
if (%year%)==(ERROR) goto endit
EXAMPLE:
rem use FDATE to verify %1, call a batch file to put it into %year%
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"@set year=">junktemp.bat
call junktemp.bat
del junktemp.bat
if errorlevel 1 echo Year parm [%1] is not valid.
if errorlevel 1 goto endit
SYMBOL CONVENTIONS
==================
The following symbols are used in specifying date formats:
SYMBOL EXAMPLE MEANING
------ ------- -------------------------------------
cc 19 century
yy 93 year
mm 02 month
zm 2 month without leading zero
dd 08 day
zd 8 day without leading zero
mn February month name
mn3 Feb month name, first 3 characters only
dow Tuesday day of week
dow3 Tue day of week, first 3 characters only
dow# 3 day of week as a number (Sunday=1, Monday = 2, etc.)
today is a "pseudodate" representing the current date
t is an alias for the "today" pseudodate
hh:mm 09:05 hours and minutes
hhmm 0905 hours and minutes
ss 09 seconds
PSEUDODATES
===========
t (or today)
can be used with either /A or /B, e.g. /Atoday or /At.
EXAMPLE
rem Get the date that is 90 days from today
FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
FDATE /Fadd /N90 /At /Omm-dd-ccyy
rem determine if this year is a leapyear
FDATE /Ff /At /OLY
tt when used in place of a 2-digit DD string, will cause
Fdate to use today's day-of-the-month.
Example: FDATE /Ff /Imm-dd-ccyy /A01-tt-1992 /Od1
tt when used in place of a 2-digit MM string, will cause
Fdate to use today's month.
Example: FDATE /Ff /Imm-dd-ccyy /Att-01-1992 /Od1
tt when used in place of a 2-digit YY string, will cause
Fdate to use today's year (CCYY).
Example: FDATE /Ff /Imm-dd-yy /A01-01-tt /Od1
Note that TT can NOT be used for only the YY part of a CCYY
input year. The following, for example, is NOT valid:
Example: FDATE /Ff /Imm-dd-ccyy /A01-01-19tt /Od1
tttt when used in place of a 4-digit CCYY string, will cause
Fdate to use today's year (CCYY).
Example: FDATE /Ff /Imm-dd-ccyy /A01-01-tttt /Od1
EXAMPLES:
Show the first Monday in the second quarter of this year
FDATE /Fw /Iccyymmdd /Atttt0301 /D2 /N1 /Od1 /P"First Monday in QTR#2: "
Show the last Friday on/before the 15th of this month.
FDATE /Fw /Iccyymmdd /Atttttt15 /D6 /N-1 /Od1 /P"Friday before the 15th: "
INPUT FORMATS
=============
NOTE
If ALL input dates are specified using the "today" pseudodate, (i.e.
/At, /Bt) then it is not necessary to supply an input format using /I.
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
ccyymmdd 19922002
mm-dd-ccyy 02-20-1992 In an input format specification, the dash
02/20/1992 symbols represent ANY non-numeric symbol.
2-5-1992 Leadin